package com.jiukuaidao.zhulin.module;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;

import com.jiukuaidao.zhulin.R;

/**
 * Author : PaiTaSuo
 * Date : 2016/6/12
 * Description :
 */
public class CommWatcher implements TextWatcher {
    public Button view;
    public int type;
//    public final static int CODEBTN = 1;
    public final static int LOGINBTN = 2;
    public final static int PWDLOGINBTN = 3;

    public CommWatcher(Button view, int type) {
        this.view = view;
        this.type = type;
    }

    @Override
    public void afterTextChanged(Editable arg0) {
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }

    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        switch (type) {
//            case CODEBTN:
//                codeBtn(arg0.length());
//                break;
            case LOGINBTN:
                codeLoginBtn(arg0.length());
                break;
            case PWDLOGINBTN:
                pwdLoginBtn(arg0.length());
                break;
        }
    }

//    public void codeBtn(int length) {
//        if (length == 11) {
//            view.setBackgroundResource(R.drawable.bg_yellow_white);
//            view.setTextColor(AppContext.getContext().getResources().getColor(R.color.yellow));
//        } else if (length < 11) {
//            view.setBackgroundResource(R.drawable.bg_gray_white_unselect);
//            view.setTextColor(AppContext.getContext().getResources().getColor(R.color.comm_assistbody));
//        }
//    }

    public void codeLoginBtn(int length) {
        if (length > 0) {
            view.setBackgroundResource(R.drawable.common_button_red_select);
        } else {
            view.setBackgroundResource(R.drawable.bg_button_gray_login);
        }
    }

    public void pwdLoginBtn(int length) {
        if (length >= 6) {
            view.setBackgroundResource(R.drawable.common_button_red_select);
        } else {
            view.setBackgroundResource(R.drawable.bg_button_gray_login);
        }
    }

}

